package com.hgw.Demo07_FlyweightPattern.Exercises14_9_4ER;

import java.util.Hashtable;

/**
 * Data time:2021/12/15 21:05
 * StudentID:2019112118
 * Author:hgw
 * Description: 享元工厂类
 */
public class NetworkEquipmentFactory {
    private static NetworkEquipmentFactory instance = new NetworkEquipmentFactory();
    private static Hashtable hb;

    private NetworkEquipmentFactory() {
        hb = new Hashtable();
        NetworkEquipment switchNE,hubNE;
        switchNE = new Switch();
        hb.put("s",switchNE);
        hubNE = new Hub();
        hb.put("h",hubNE);
    }

    public static NetworkEquipmentFactory getInstance() {
        return instance;
    }

    public static NetworkEquipment getNetworkEquipment(String name) {
        return (NetworkEquipment) hb.get(name);
    }
}
